package v2.parser

/**
 * @author bweber
 * @version $Rev$, $Date$
 */

class Single private (val typeref:TypeRef,var slots:List[Slot]) extends Value with Slotted with Linkable {
  override def toString() = {
    "single of type " + typeref + " with slots " + slots
  }
  
  def getType() = {
    Type(typeref)
  }
  
}

object Single {
  
  def apply(typeref:TypeRef,slots:Slot*) = {
    new Single(typeref,slots.toList)
  }
  
  def apply(typeref:TypeRef,slots:List[Slot]) = {
    new Single(typeref,slots)
  }
  
  // creates an empty single instance
  def apply(_type:Type) = {
    var slots = List[Slot]()
    for ( attrdef <- _type.attrdefs ) {
       slots = Slot(attrdef.name,null) :: slots
    }
    new Single(Type.typeRef(_type.name),slots)
  }
}